/**
 * @file    woshDefs.h
 * @brief   low-level defines and pragma(s)
 *
 *
 ****************************************************************************
 * @version 0.01 $Id: woshDefs.h 2881 2010-08-09 09:57:06Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ******************************************************************************/

#ifndef __WOSH_DEFINITIONS_H__
 #define __WOSH_DEFINITIONS_H__

 #include <woshConfig.h>
 #include <woshMacros.h>


 #define _WOSH_VER_MAJOR			0.8			///< current framework version (major)
 #define _WOSH_VER_MINOR			471			///< current framework version (minor)

 #define _WOSH_VER_CODENAME			"icarus"	///< current framework version as codename, it is changed on milestone-release


 #define _WOSH_CREATOR				"Alessandro Polo <contact@alessandropolo.name>"
 #define _WOSH_CREATOR_WEB			"http://www.alessandropolo.name"

 #define _WOSH_WEB_SITE				"http://wosh.sourceforge.net/"
 #define _WOSH_WEB_DOCS				"http://wosh.sourceforge.net/doc/"
 #define _OPEN_SMART_HOME_WEB		"http://www.opensmarthome.com"
 #define _WOSH_DONATE_URL			"https://sourceforge.net/project/project_donations.php?group_id=274637"



# ifdef _OS_POSIX
#  define _WOSH_BUILT_PLATFORM		"POSIX"
# else
#  ifdef _OS_WIN32
#   define _OS_WINxx
#   define _WOSH_BUILT_PLATFORM		"WIN32"
#  endif
#  ifdef _OS_WINCE
#   define _OS_WINxx
//   #define _WOSH_BUILT_PLATFORM		"WINCE"
#  endif
# endif //_OS_POSIX
# ifndef _WOSH_BUILT_PLATFORM
#  define _WOSH_BUILT_PLATFORM		"UNKNOWN"
# endif

#ifdef _MSC_VER
 #define _CRT_SECURE_NO_WARNINGS
 #define WIN32_VS
#endif

#if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
#  if defined( WOSH_EXPORTS ) || defined( DLL_EXPORT )
#    define WOSH_API __declspec( dllexport )
#  else
#    if defined( WOSH_IMPORTS ) || defined( DLL_IMPORT )
#      define WOSH_API __declspec( dllimport )
#    endif
#  endif
#endif

#ifndef WOSH_API
#  define WOSH_API
#endif

/**
 * @typedef WRESULT
 * @brief   Standard return type for WOSH methods is defined as an integer,
 *          Reserved values are [0, 512], components may use out of range values for custom context
 *          Sample: WRESULT myMethod() { return WRET_OK; }
 */
 typedef int WRESULT;

#define LIMIT_INT_MIN		-32767
#define LIMIT_INT_MAX		0x7FFFFFFF
#define LIMIT_UINT_MAX		0xFFFFFFFFU

#define LIMIT_LONG_MIN		-2147483647
#define LIMIT_LONG_MAX		0x7FFFFFFFL

#define LIMIT_ULONG_MAX		0xffffffffUL

#define LIMIT_LLONG_MIN		(-(long long)0x8000000000000000LL)
#define LIMIT_LLONG_MAX		0x7FFFFFFFFFFFFFFFLL
#define LIMIT_ULLONG_MAX	0xFFFFFFFFFFFFFFFFULL


 // ENUM
 // http://mateusz.loskot.net/2009/05/24/size-of-enumeration-type-in-c/

#ifdef __GNUC__
 #define __STDC_FORMAT_MACROS // FORCE inttypes to define PREFIXes
 #include <inttypes.h> // includes <stdint.h>
 // The following works for me with cygwin/gcc on Windows XP and for gcc 32-bit and 64-bit Linux
 typedef uint64_t uint64;	//typedef unsigned long long uint64;
 typedef int64_t int64;		//typedef long long int64;
#else // such as MSC
 #define PRIu64 "I64u"		// usage: printf("timestamp = %" PRId64 "\n", timestamp++);
 #define PRId64 "I64d"		// usage: printf("%"PRId64"", value),   %I64d works
 typedef unsigned __int64 uint64;
 typedef __int64 int64;
#endif

 typedef unsigned short uint16;
 typedef unsigned int uint32;
 typedef unsigned char uint8;
 typedef short int16;
 typedef int int32;
 typedef char int8;


/**
 * @namespace wosh
 * @brief     Standard root namespace of WOSH framework.
 **/
namespace wosh {

/**
 * @brief  Standard return codes are defined as pow of 2, so you may add result
 *         and still be able to extract each original error from the sum (15=8+4+2+1)
 */
 #define WRET_OK					0		///< no errors found
 #define WRET_ERR_PARAM				1		///< illegal parameter(s)
 #define WRET_ERR_INTERNAL			2		///< internal routine error
 #define WRET_ERR_ILLEGAL_USE		4		///< illegal use of function (forbidden)
 #define WRET_ERR_DEPRECATED		8		///< method is deprecated

 #define WRET_ERR_WRONG_STATE		16		///< call is not valid in current state
 #define WRET_ERR_UNKNOWN			32		///< unknown (not handled) error

 #define WRET_ERR_SECURITY			64		///< a security/permission error occurred

 #define WRET_NOT_IMPLEMENTED		512		///< method is actually not implemented


/**
 * @namespace wosh::application
 * @brief     Contains official WOSH applications (implementation and their classes).
 **/
 namespace application { };


}; // namespace wosh


#endif // __WOSH_DEFINITIONS_H__
